<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
      <el-row>
        <el-col :span="6">
          <el-form-item label="隔离人员姓名" prop="segreName">
            <el-input
              v-model="queryParams.segreName"
              placeholder="请输入隔离人员姓名"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="身份证号码" prop="idCard">
            <el-input
              v-model="queryParams.idCard"
              placeholder="请输入身份证号码"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="手机号" prop="phone">
            <el-input
              v-model="queryParams.phone"
              placeholder="请输入手机号"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
            <el-form-item label="所属机构" prop="deptId" label-width="70px">
              <treeselect style="width: 220px" v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择所属机构" />
            </el-form-item>
        </el-col>
      </el-row>


      <!--      <el-form-item label="年龄" prop="age">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.age"-->
      <!--          placeholder="请输入年龄"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->



      <!--      <el-form-item label="身体健康情况(0健康 1异常)" prop="isHealth">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.isHealth"-->
      <!--          placeholder="请输入身体健康情况(0健康 1异常)"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="每日核酸检测结果(0阴性 1阳性)" prop="nucleicResult">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.nucleicResult"-->
      <!--          placeholder="请输入每日核酸检测结果(0阴性 1阳性)"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
<!--      <el-form-item label="人员类别" prop="personnelCategory">-->
<!--        <el-input-->
<!--          v-model="queryParams.personnelCategory"-->
<!--          placeholder="请输入人员类别"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <!--      <el-form-item label="隔离开始时间" prop="segStartTime">-->
      <!--        <el-date-picker clearable-->
      <!--          v-model="queryParams.segStartTime"-->
      <!--          type="date"-->
      <!--          value-format="yyyy-MM-dd"-->
      <!--          placeholder="请选择隔离开始时间">-->
      <!--        </el-date-picker>-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="隔离结束时间" prop="segEndTime">-->
      <!--        <el-date-picker clearable-->
      <!--          v-model="queryParams.segEndTime"-->
      <!--          type="date"-->
      <!--          value-format="yyyy-MM-dd"-->
      <!--          placeholder="请选择隔离结束时间">-->
      <!--        </el-date-picker>-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="隔离时间" prop="segTime">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.segTime"-->
      <!--          placeholder="请输入隔离时间"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['prevention:segregater:add']"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['prevention:segregater:edit']"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['prevention:segregater:remove']"
        >删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['prevention:segregater:export']"
        >导出
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
          v-has-permi="['prevention:segregater:export']"
        >导入
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="segregaterList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column v-if="columns[0].visible" label="隔离人员id" align="center" prop="segreId"/>
      <el-table-column v-if="columns[1].visible" label="隔离人员姓名" align="center" prop="segreName"/>
      <el-table-column v-if="columns[2].visible" label="身份证号码" align="center" prop="idCard"/>
      <el-table-column v-if="columns[3].visible" label="性别" align="center" prop="sex">
        <template slot-scope="scope">
          <span v-if="scope.row.sex === '0'">男</span>
          <span v-if="scope.row.sex === '1'">女</span>
        </template>
      </el-table-column>
      <el-table-column v-if="columns[4].visible" label="年龄" align="center" prop="age"/>
      <el-table-column v-if="columns[5].visible" label="所属机构" align="center" prop="dept.deptName" key="deptName"/>
      <el-table-column v-if="columns[6].visible" label="所属机构id" align="center" prop="deptId"/>
      <el-table-column v-if="columns[7].visible" label="手机号" align="center" prop="phone"/>
      <el-table-column v-if="columns[8].visible" label="现居住地址" align="center" prop="currentAddress"/>
      <el-table-column v-if="columns[9].visible" label="隔离病房id" align="center" prop="wardId"/>
      <el-table-column v-if="columns[10].visible" label="隔离病房名" align="center" prop="wardName"/>
      <el-table-column v-if="columns[11].visible" label="防疫人员姓名" align="center" prop="workerName"/>
      <el-table-column v-if="columns[12].visible" label="当日体温情况" align="center" prop="temperature"/>
      <el-table-column v-if="columns[13].visible" label="身体健康情况" align="center" prop="isHealth">
        <template slot-scope="scope">
          <span v-if="scope.row.isHealth === '0'">健康</span>
          <span style="font-weight: bolder;color: red" v-if="scope.row.isHealth === '1'">异常</span>
        </template>
      </el-table-column>
      <el-table-column v-if="columns[14].visible" label="每日核酸检测结果" align="center" prop="nucleicResult">
        <template slot-scope="scope">
          <span v-if="scope.row.nucleicResult === '0'">阴性</span>
          <span style="font-weight: bolder;color: red" v-if="scope.row.nucleicResult === '1'">阳性</span>
        </template>
      </el-table-column>
      <el-table-column v-if="columns[15].visible" label="人员类别" align="center" prop="personnelCategory">
        <template slot-scope="scope">
          <span v-if="scope.row.personnelCategory === '0'">学生</span>
          <span v-if="scope.row.personnelCategory === '1'">教师</span>
          <span v-if="scope.row.personnelCategory === '3'">其他</span>
        </template>
      </el-table-column>
      <el-table-column v-if="columns[16].visible" label="隔离开始时间" align="center" prop="segStartTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.segStartTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column v-if="columns[17].visible" label="隔离结束时间" align="center" prop="segEndTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.segEndTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column v-if="columns[18].visible" label="隔离时间" align="center" prop="segTime"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['prevention:segregater:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['prevention:segregater:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改隔离人员信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="110px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="隔离人员姓名" prop="segreName">
              <el-input v-model="form.segreName" placeholder="请输入隔离人员姓名"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="身份证号码" prop="idCard">
              <el-input v-model="form.idCard" placeholder="请输入身份证号码"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="年龄" prop="age">
              <el-input v-model="form.age" placeholder="请输入年龄"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="所属机构" prop="deptId">
              <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择所属机构" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="手机号" prop="phone">
              <el-input v-model="form.phone" placeholder="请输入手机号"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="现居住地址" prop="currentAddress">
              <el-input v-model="form.currentAddress" placeholder="请输入现居住地址"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="隔离病房名" prop="wardName">
              <el-select v-model="form.wardName" placeholder="请选择隔离病房">
                <el-option v-for="(item) in isowardOption" :key="item.wardId" :label="item.wardName"
                           :value="item.wardName">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="防疫人员姓名" prop="workerName">
              <el-select v-model="form.workerName" placeholder="请选择防疫人员">
                <el-option v-for="(item) in workerOption" :key="item.workerId" :label="item.workerName"
                           :value="item.workerName">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="当日体温情况" prop="temperature">
              <el-input v-model="form.temperature" placeholder="请输入当日体温情况"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="身体健康情况" prop="isHealth">
              <el-select v-model="form.isHealth" placeholder="请选择健康状况">
                <el-option v-for="(item) in isHealthType" :key="item.type" :label="item.name"
                           :value="item.type"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="核酸检测结果" prop="nucleicResult">
              <el-select v-model="form.nucleicResult" placeholder="请选择核酸结果">
                <el-option v-for="(item) in nucleicResultType" :key="item.type" :label="item.name"
                           :value="item.type"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="人员类别" prop="personnelCategory">
              <el-select v-model="form.personnelCategory" placeholder="请选择人员类别">
                <el-option  v-for="(item) in personnelCategoryType" :key="item.type" :label="item.name" :value="item.type"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="隔离开始时间" prop="segStartTime">
              <el-date-picker clearable
                              v-model="form.segStartTime"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择隔离开始时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="隔离结束时间" prop="segEndTime">
              <el-date-picker clearable
                              v-model="form.segEndTime"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择隔离结束时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="隔离时间" prop="segTime">
              <el-input v-model="form.segTime" placeholder="请输入隔离时间"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="性别" prop="sex">
              <el-select v-model="form.sex" placeholder="请选择性别">
                <el-option  v-for="(item) in sexType" :key="item.type" :label="item.name" :value="item.type"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 用户导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.updateSupport"/>
            是否更新已经存在的数据
          </div>
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px; vertical-align: baseline;"
                   @click="importTemplate">下载模板
          </el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {listIsowardList} from "../../../api/prevention/isoward";

const sexType = [
  {type: '0', name: '男'},
  {type: '1', name: '女'},
]
const isHealthType = [
  {type: '0', name: '健康'},
  {type: '1', name: '异常'},
]
const nucleicResultType = [
  {type: '0', name: '阴性'},
  {type: '1', name: '阳性'},
]

const personnelCategoryType=[
  {type: '0',name:'学生'},
  {type: '1',name:'教师'},
  {type: '2',name:'其他人员'}
]
import {
  listSegregater,
  getSegregater,
  delSegregater,
  addSegregater,
  updateSegregater
} from "@/api/prevention/segregater";
import {getToken} from "@/utils/auth";
import {listWorkerList} from "../../../api/prevention/worker";
import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import {listSegregater2} from "../../../api/prevention/segregater";
export default {
  components:{Treeselect},
  name: "Segregater",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      sexType,
      nucleicResultType,
      isHealthType,
      personnelCategoryType,
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      deptName: undefined,
      // 隔离人员信息表格数据
      segregaterList: [],
      //隔离病房选型
      isowardOption: [],
      //检测人员选项
      workerOption: [],
      deptOptions:undefined,
      defaultProps: {
        children: "children",
        label: "label"
      },

      columns: [
        {key: 0, label: '隔离人员id', visible: false},
        {key: 1, label: '隔离人员姓名', visible: true},
        {key: 2, label: '身份证号码', visible: false},
        {key: 3, label: '性别', visible: true},
        {key: 4, label: '年龄', visible: true},
        {key: 5, label: '所属机构', visible: true},
        {key: 6, label: '所属机构id', visible: false},
        {key: 7, label: '手机号', visible: false},
        {key: 8, label: '现居住地址', visible: false},
        {key: 9, label: '隔离病房id', visible: false},
        {key: 10, label: '隔离病房名', visible: true},
        {key: 11, label: '防疫人员姓名', visible: true},
        {key: 12, label: '当日体温情况', visible: true},
        {key: 13, label: '健康情况', visible: true},
        {key: 14, label: '每日核酸检测结果', visible: true},
        {key: 15, label: '人员类别', visible: false},
        {key: 16, label: '隔离开始时间', visible: false},
        {key: 17, label: '隔离结束时间', visible: false},
        {key: 18, label: '隔离时间', visible: false},
      ],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      //导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: {Authorization: "Bearer " + getToken()},
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/prevention/segregater/importData"
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        segreName: null,
        idCard: null,
        sex: null,
        age: null,
        deptId: null,
        phone: null,
        currentAddress: null,
        wardId: null,
        wardName: null,
        workerId: null,
        workerName: null,
        temperature: null,
        isHealth: null,
        nucleicResult: null,
        personnelCategory: null,
        segStartTime: null,
        segEndTime: null,
        segTime: null
      },
      paramsWorker:{
        workerName: null,
        workerAge: null,
        sex: null,
        idCard: null,
        phone: null,
        currentAddress: null,
        temperature: null,
        isHealth: null,
        nucleicResult: null
      },
      paramsIsoWard:{
        wardName: null,
        wardStatus: null,
        startTime: null,
        closeTime: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        segreName: [
          { required: true, message: "名称不能为空", trigger: "blur" },
          { min: 2, max: 20, message: '名称长度必须介于 2 和 20 之间', trigger: 'blur' }
        ],
        idCard: [
          { pattern: /^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
            message: "请输入正确的身份证号码",
            trigger: "blur",
            required: true
          }
        ],
        phone: [
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: "请输入正确的手机号码",
            trigger: "blur"
          }
        ],
        deptId:[
          {required:true,message:'请选择机构名称',trigger:'blur'}
        ]

      },
      filters: {
        sexTypeFilter(type) {
          const sexTy = sexType.find(obj => obj.type === type);
          return sexTy ? sexTy.name : null;
        },

        nucleicResultType(type) {
          const nucleicResultTy = nucleicResultType.find(obj => obj.type === type);
          return nucleicResultTy ? nucleicResultTy.name : null;
        },
        isHealthTypeFilter(type) {
          const isHealthTy = isHealthType.find(obj => obj.type === type);
          return isHealthTy ? isHealthTy.name : null;
        },
        personnelCategoryTypeFilter(type) {
          const personnelCategoryTy = personnelCategoryType.find(obj => obj.type === type);
          return personnelCategoryTy ? personnelCategoryTy.name : null;
        },
      }
    };
  },
  watch: {
    // 根据名称筛选部门树
    deptName(val) {
      this.$refs.tree.filter(val);
    }
  },
  created() {
    this.getList();
    this.getTreeselect();
  },
  methods: {
    /** 查询隔离人员信息列表 */
    getList() {
      this.loading = true;
      listSegregater2(this.queryParams).then(response => {
        this.segregaterList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 查询部门下拉树结构 */
    getTreeselect() {
      treeselect().then(response => {
        this.deptOptions = response.data
        // console.log(this.deptOptions);
      });
    },
    // 筛选节点
    filterNode(value, data) {
      if (!value) return true;
      return data.label.indexOf(value) !== -1;
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        segreId: null,
        segreName: null,
        idCard: null,
        sex: null,
        age: null,
        deptId: null,
        phone: null,
        currentAddress: null,
        wardId: null,
        wardName: null,
        workerId: null,
        workerName: null,
        temperature: null,
        isHealth: null,
        nucleicResult: null,
        personnelCategory: null,
        segStartTime: null,
        segEndTime: null,
        segTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.segreId)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.getTreeselect();
      this.open = true;
      listWorkerList(this.paramsWorker).then(res => {
        // console.log(res);
        this.workerOption=res;
        // console.log(this.workerOption);
      });
      listIsowardList(this.paramsIsoWard).then(res => {
        this.isowardOption=res;
      });
      this.title = "添加隔离人员信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.getTreeselect();
      const segreId = row.segreId || this.ids
      getSegregater(segreId).then(response => {
        this.form = response.data;
        listWorkerList(this.paramsWorker).then(res => {
          // console.log(res);
          this.workerOption=res;
          // console.log(this.workerOption);
        });
        listIsowardList(this.paramsIsoWard).then(res => {
          this.isowardOption=res;
        });
        this.open = true;
        this.title = "修改隔离人员信息";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.segreId != null) {
            updateSegregater(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addSegregater(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const segreIds = row.segreId || this.ids;
      this.$modal.confirm('是否确认删除隔离人员信息编号为"' + segreIds + '"的数据项？').then(function () {
        return delSegregater(segreIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('prevention/segregater/export', {
        ...this.queryParams
      }, `segregater_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "隔离人员导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('prevention/segregater/importTemplate', {}, `隔离人员信息表_模板_${new Date().getTime()}.xlsx`)
    },

    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
// 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert(response.msg, "导入结果", {dangerouslyUseHTMLString: true});
      this.getList();
    },
// 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
  },
};
</script>


